package com.learn.project2.controller.admin;

import com.learn.project2.bean.MarketKeyword;
import com.learn.project2.model.bo.admin.keyword.KeywordCreateBO;
import com.learn.project2.model.bo.admin.keyword.KeywordDeleteBO;
import com.learn.project2.model.bo.admin.keyword.KeywordUpdateBO;
import com.learn.project2.model.vo.admin.keyword.KeywordCreateVO;
import com.learn.project2.model.vo.admin.keyword.KeywordListVO;
import com.learn.project2.service.admin.keyword.KeywordService;
import com.learn.project2.utils.Result;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 曹源
 * @version 1.0git
 * @description: 商场管理/关键词 Admin/keyword的控制方法
 * @date 2022/1/6 21:08
 */
@RestController
@RequestMapping("admin/keyword")
public class KeywordController {


    @Autowired
    KeywordService keywordService;

    Result result;

    /**
     * @description: 商场管理/关键词/查询 Admin/keyword/list的控制方法
     * @param:
     * @return:
     * @author 曹源
     * @date: 2022-01-07 10:48
     */
    @RequestMapping("list")
    @RequiresPermissions("admin:keyword:list")
    public Result list(Integer page, Integer limit, String keyword, String url, String sort, String order) {
        KeywordListVO keywordListVO = keywordService.selectList(page, limit, keyword, url, sort, order);
        return result.ok(keywordListVO);
    }
/**
 * @description:  商场管理/关键词/添加 Admin/keyword/create的控制方法
 * @param:
 * @return:
 * @author 曹源
 * @date: 2022-01-07 17:05
 */
    @RequestMapping("create")
    @RequiresPermissions("admin:keyword:create")
    public Result create(@RequestBody KeywordCreateBO keywordCreateBO) {
        KeywordCreateVO keywordCreateVO = keywordService.insert(keywordCreateBO);
        return result.ok(keywordCreateVO);
    }
/**
 * @description:  商场管理/关键词/编辑 Admin/keyword/update的控制方法
 * @param:
 * @return:
 * @author 曹源
 * @date: 2022-01-07 20:40
 */
    @RequestMapping("update")
    @RequiresPermissions("admin:keyword:update")
    public Result update(@RequestBody KeywordUpdateBO keywordUpdateBO) {
        MarketKeyword keywordUpdateVO = keywordService.update(keywordUpdateBO);
        return result.ok(keywordUpdateVO);
    }
/**
 * @description: 商场管理/关键词/删除 Admin/keyword/delete的控制方法
 * @param:
 * @return:
 * @author 曹源
 * @date: 2022-01-07 22:18
 */
    @PostMapping("delete")
    @RequiresPermissions("admin:keyword:delete")
    public Result delete(@RequestBody KeywordDeleteBO keywordDeleteBO) {
        keywordService.delete(keywordDeleteBO);
        return result.ok();
    }
}
